﻿using System;
using System.Windows.Data;
namespace MyDesktopMicroBlog.Converter
{
    [ValueConversion(typeof(string),typeof(string))]
    class DateTimeFormatConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                return mBlogAPI.Utils.DateTimeHelper.GetNormalDateStringFromString(value.ToString());
            }
            catch(FormatException fe)
            {
                throw new FormatException("format does not supported, you should only parse this type Thu Dec 09 23:30:20 +0800 2010 " + fe.Message);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("we currently do not support this method!");
        }
    }
}
